<template>
	<view class="container">
		<view class="feedback-box">
			<view class="text-box">
				<textarea v-model="formData.content" maxlength="100" auto-height placeholder="请输入您的意见或建议(100字以内)" placeholder-class="my-placeholder"></textarea>
			</view>
			<view class="submit-btn" @tap="doSubmit">提交</view>
		</view>
	</view>
</template>

<script>
	import { myRequest, showToastMsg } from '../../utils'
	
	export default {
		data() {
			return {
				loading: false,
				formData: {
					content: ''
				}
			}
		},
		
		methods: {
			
			doSubmit() {
				const that = this
				let d = that.formData
				
				if (d.content.length <= 0) {
					return showToastMsg('请输入反馈内容')
				}
				
				if (that.loading) {
					return
				}
				
				that.loading = true
				uni.showLoading({
					title: '正在提交'
				})
				
				let success = function(res) {
					that.loading = false
					uni.hideLoading()
					if (res.data.code != 20000) {
						return showToastMsg(res.data.message)
					}
					showToastMsg(res.data.message)
					that.formData.content = ''
				}
				
				let param = {
					url: '/feedback/submit',
					data: that.formData
				}
				
				myRequest(param, success)
			}
			
		}
	}
</script>

<style>
	page {
		background-color: #eeeeee;
	}
	
	.container {
		width: 750rpx;
		height: auto;
	}
	
	.feedback-box {
		width: 750rpx;
		background-color: #ffffff;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 20rpx;
		padding-bottom: 30rpx;
		margin-top: 20rpx;
	}
	
	.text-box {
		width: 700rpx;
		height: 400rpx;
	}
	
	.my-placeholder {
		font-size: 30rpx;
		color: #666666;
	}
	
	.submit-btn {
		width: 700rpx;
		height: 88rpx;
		background-color: #5683ec;
		border-radius: 44rpx;
		font-size: 36rpx;
		color: #ffffff;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	
	textarea {
		color: #666666;
	}
</style>
